Skip to content

fix(event_handler): always add 422 response to the schema #3995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 21, 2024

Conversation

rubenfonseca
Copy link
Contributor

@rubenfonseca rubenfonseca commented Mar 21, 2024

Issue number: #3600

Summary

Changes

Please provide a summary of what's being changed

This PR makes sure that the 422 error is always added to the OpenAPI schema, even when the user is customizing the response.
It also fixes the default schema of the 422 error to not have a "msg" field, for security reasons.
Also took the opportunity to simplify the code to make it easier to read.

User experience

Please share what the user experience looks like before and after this change

After this PR, the user can still customize the openapi responses, while maintaining the 422 error that is generated when there is a validation error.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 21, 2024
@github-actions github-actions bot added the bug Something isn't working label Mar 21, 2024
@rubenfonseca rubenfonseca marked this pull request as ready for review March 21, 2024 14:16
@rubenfonseca rubenfonseca requested review from a team and leandrodamascena March 21, 2024 14:16
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rubenfonseca! The PR appears to be in a very good shape, with all functionality working as expected. I'm wondering if it's beneficial to include additional tests to safeguard against unintentional overriding of the client-defined 422 response when setting it specifically in the route definition.
What do you think?

@rubenfonseca
Copy link
Contributor Author

additional tests to safeguard against unintentional overriding of the client-defined 422 response when setting it specifically in

great idea

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVED!

@rubenfonseca rubenfonseca merged commit 16bdeaf into develop Mar 21, 2024
14 checks passed
@rubenfonseca rubenfonseca deleted the rf/3600 branch March 21, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working event_handlers size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Event handler Swagger doesnt add 422 response to openapi when adding custom responses
2 participants